/*
 * File: /src/filter/index.js
 * Project: shop_admin
 * version: 0.1.0
 * Created Date: 2020-11-08 23:05:55
 * Author: Xiaotao
 * -----
 * Last Modified: Sun Nov 08 2020
 * Modified By: xiaotao
 * -----
 * Copyright (c) 2020 Gray Snail
 */

import Vue from 'vue'

Vue.filter('dataFormat', function(originVal) {
  const dt = new Date(originVal)

  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // yyyy-mm-dd hh:mm:ss
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
